package views;

import java.awt.Font;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableModel;

public class ReferencesView extends JPanel {
	
	public JScrollPane scpOrganizations;
	
	public DefaultTableModel tblModelOrganizations;
	public JTable tblOrganizations;
	public JButton btnAddOrganization;
	public JButton btnUpdateOrganization;
	
	public JScrollPane scpAddUpdate;
	public JLabel lblAddupdateOrganization;
	
	public JTextField txtName;
	public JTextField txtType;
	public JComboBox<String> cmbStatus;
	
	public JButton btnCancel;
	public JButton btnSave;
	
	public ReferencesView() {
		this.setName("References");
		this.setSize(770, 480);
		this.setLayout(null);
		
		scpOrganizations = new JScrollPane();
		scpOrganizations.setBounds(10, 10, 440, 460);
		this.add(scpOrganizations);
		
		tblModelOrganizations = new DefaultTableModel(new Object[][] {},
				new String[] {"Organization Name", "Organization Type", "Status"});
		
		tblOrganizations = new JTable(tblModelOrganizations) {
			public boolean isCellEditable(int row, int col) {
            	return false;
            }
		};
		tblOrganizations.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		tblOrganizations.getColumnModel().getColumn(0).setPreferredWidth(200);
		tblOrganizations.getColumnModel().getColumn(1).setPreferredWidth(190);
		tblOrganizations.getColumnModel().getColumn(2).setPreferredWidth(50);
		
		scpOrganizations.setViewportView(tblOrganizations);
		
		btnAddOrganization = new JButton("Add Organization");
		btnAddOrganization.setBounds(510, 65, 200, 25);
		btnAddOrganization.setFont(new Font("Arial", Font.PLAIN, 12));
		this.add(btnAddOrganization);
		
		btnUpdateOrganization = new JButton("Update Organization");
		btnUpdateOrganization.setFont(new Font("Arial", Font.PLAIN, 12));
		btnUpdateOrganization.setBounds(510, 100, 200, 25);
		this.add(btnUpdateOrganization);
		
		scpAddUpdate = new JScrollPane();
		scpAddUpdate.setBounds(460, 170, 300, 250);
		scpAddUpdate.setVisible(false);
		this.add(scpAddUpdate);
		
		JPanel panel = new JPanel();
		panel.setSize(300, 250);
		panel.setLayout(null);
		scpAddUpdate.setViewportView(panel);
		
		lblAddupdateOrganization = new JLabel();
		lblAddupdateOrganization.setHorizontalAlignment(SwingConstants.CENTER);
		lblAddupdateOrganization.setFont(new Font("Arial Black", Font.PLAIN, 20));
		lblAddupdateOrganization.setBounds(10, 10, 278, 25);
		panel.add(lblAddupdateOrganization);
		
		JLabel lblOrganizationName = new JLabel("Organization Name");
		lblOrganizationName.setFont(new Font("Arial", Font.PLAIN, 12));
		lblOrganizationName.setBounds(10, 45, 278, 20);
		panel.add(lblOrganizationName);
		
		JLabel lblOrganizationType = new JLabel("Organization Type");
		lblOrganizationType.setFont(new Font("Arial", Font.PLAIN, 12));
		lblOrganizationType.setBounds(10, 95, 278, 20);
		panel.add(lblOrganizationType);
		
		JLabel lblOrganizationStatus = new JLabel("Organization Status");
		lblOrganizationStatus.setFont(new Font("Arial", Font.PLAIN, 12));
		lblOrganizationStatus.setBounds(10, 145, 278, 20);
		panel.add(lblOrganizationStatus);
		
		txtName = new JTextField();
		txtName.setFont(new Font("Arial", Font.PLAIN, 12));
		txtName.setBounds(10, 65, 278, 20);
		panel.add(txtName);
		txtName.setColumns(10);
		
		txtType = new JTextField();
		txtType.setFont(new Font("Arial", Font.PLAIN, 12));
		txtType.setColumns(10);
		txtType.setBounds(10, 115, 278, 20);
		panel.add(txtType);
		
		cmbStatus = new JComboBox<String>();
		cmbStatus.setModel(new DefaultComboBoxModel<String>(new String[] {"Active", "Inactive"}));
		cmbStatus.setFont(new Font("Arial", Font.PLAIN, 12));
		cmbStatus.setBounds(10, 165, 278, 20);
		panel.add(cmbStatus);
		
		btnCancel = new JButton("Cancel");
		btnCancel.setFont(new Font("Arial", Font.PLAIN, 12));
		btnCancel.setBounds(10, 210, 100, 25);
		panel.add(btnCancel);
		
		btnSave = new JButton("Save");
		btnSave.setFont(new Font("Arial", Font.PLAIN, 12));
		btnSave.setBounds(188, 210, 100, 25);
		panel.add(btnSave);
	}
}
